﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using PhatPhucLoc.util;
using PhatPhucLoc.model;
using System.Data.SqlClient;

namespace PhatPhucLoc.dao
{
    class NhomHangDAO
    {
        public static DataTable GetAll()
        {
            return DataUtil.executeStore("sp_NhomHang_GetAll", null);
        }

        public static Boolean Insert(NhomHangModel _model)
        {
            SqlParameter[] param = new SqlParameter[2];
            int i = 0;
            param[i] = new SqlParameter("Ten", SqlDbType.NVarChar);
            param[i++].Value = _model.Ten;
            param[i] = new SqlParameter("Ghi_chu", SqlDbType.NVarChar);
            param[i++].Value = _model.GhiChu;
            return DataUtil.executeNonStore("sp_NhomHang_Insert", param);
        }

        public static Boolean Update(NhomHangModel _model)
        {
            SqlParameter[] param = new SqlParameter[3];
            int i = 0;
            param[i] = new SqlParameter("ID", SqlDbType.NVarChar);
            param[i++].Value = _model.Id;
            param[i] = new SqlParameter("Ten", SqlDbType.NVarChar);
            param[i++].Value = _model.Ten;
            param[i] = new SqlParameter("Ghi_chu", SqlDbType.NVarChar);
            param[i++].Value = _model.GhiChu;
            return DataUtil.executeNonStore("sp_NhomHang_Update", param);
        }

    }
}
